package com.aiyige.base.db.table;

import android.os.Parcel;
import android.os.Parcelable;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

/**
 * Created by zhuyakun on 2017/11/10.
 */
@DatabaseTable(tableName = "UploadFile")
public class UploadFile implements Parcelable {
    public static final String ID_FIELD = "id";
    public static final String CONTROL_OPTION_FIELD = "controlOption";
    public static final String PROGRESS_STATUS_FIELD = "progressStatus";
    public static final String UPLOAD_TIMESTAMP_FIELD = "uploadTimestamp";
    public static final String RETRY_COUNT_FIELD = "retryCount";
    public static final String PARENT_ID_FIELD = "parentId";
    public static final String PARENT_TYPE_FIELD = "parentType";
    public static final String USER_ID_FIELD = "userId";
    public static final String FILE_TYPE_FIELD = "fileType";
    public static final String UPLOADED_SIZE_FIELD = "uploadedSize";
    public static final String TRANSCODE_PROGRESS_FIELD = "transcodeProgress";
    public static final String FILE_LOCAL_URL = "fileLocalUrl";
    public static final String TOTAL_SIZE = "totalSize";
    public static final String PERSISTENET_ID_FIELD = "persistentId";
    public static final String STORE_KEY_FIELD = "storeKey";
    @DatabaseField(generatedId = true, columnName = ID_FIELD)
    int id;
    @DatabaseField(columnName = PARENT_ID_FIELD)
    String parentId;
    @DatabaseField(columnName = PARENT_TYPE_FIELD)
    int parentType;
    @DatabaseField(columnName = USER_ID_FIELD)
    String userId;
    @DatabaseField(columnName = STORE_KEY_FIELD)
    String storeKey;
    @DatabaseField(columnName = FILE_LOCAL_URL)
    String fileLocalUrl;
    @DatabaseField
    String coverStoreKey;
    @DatabaseField
    String coverUrl;
    @DatabaseField(columnName = TOTAL_SIZE)
    long totalSize;
    @DatabaseField(columnName = UPLOADED_SIZE_FIELD)
    long uploadedSize;
    @DatabaseField(columnName = PROGRESS_STATUS_FIELD)
    int progressStatus;
    @DatabaseField(columnName = FILE_TYPE_FIELD)
    int fileType;
    @DatabaseField(columnName = CONTROL_OPTION_FIELD)
    int controlOption;
    @DatabaseField
    String title;
    @DatabaseField
    String description;
    @DatabaseField
    int bussinessType;
    @DatabaseField
    long duration;
    @DatabaseField(columnName = UPLOAD_TIMESTAMP_FIELD)
    long uploadTimestamp;
    @DatabaseField(columnName = RETRY_COUNT_FIELD)
    int retryCount;
    @DatabaseField(columnName = TRANSCODE_PROGRESS_FIELD)
    int transcodeProgress;
    @DatabaseField(columnName = PERSISTENET_ID_FIELD)
    String persistentId;

    public UploadFile() {
    }

    private UploadFile(Builder builder) {
        setId(builder.id);
        setParentId(builder.parentId);
        setParentType(builder.parentType);
        setUserId(builder.userId);
        setStoreKey(builder.storeKey);
        setFileLocalUrl(builder.fileLocalUrl);
        setCoverStoreKey(builder.coverStoreKey);
        setCoverUrl(builder.coverUrl);
        setTotalSize(builder.totalSize);
        setUploadedSize(builder.uploadedSize);
        setProgressStatus(builder.progressStatus);
        setFileType(builder.fileType);
        setControlOption(builder.controlOption);
        setTitle(builder.title);
        setDescription(builder.description);
        setBussinessType(builder.bussinessType);
        setDuration(builder.duration);
        setUploadTimestamp(builder.uploadTimestamp);
        setRetryCount(builder.retryCount);
        setTranscodeProgress(builder.transcodeProgress);
        setPersistentId(builder.persistentId);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public int getParentType() {
        return parentType;
    }

    public void setParentType(int parentType) {
        this.parentType = parentType;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getStoreKey() {
        return storeKey;
    }

    public void setStoreKey(String storeKey) {
        this.storeKey = storeKey;
    }

    public String getFileLocalUrl() {
        return fileLocalUrl;
    }

    public void setFileLocalUrl(String fileLocalUrl) {
        this.fileLocalUrl = fileLocalUrl;
    }

    public String getCoverStoreKey() {
        return coverStoreKey;
    }

    public void setCoverStoreKey(String coverStoreKey) {
        this.coverStoreKey = coverStoreKey;
    }

    public String getCoverUrl() {
        return coverUrl;
    }

    public void setCoverUrl(String coverUrl) {
        this.coverUrl = coverUrl;
    }

    public long getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(long totalSize) {
        this.totalSize = totalSize;
    }

    public long getUploadedSize() {
        return uploadedSize;
    }

    public void setUploadedSize(long uploadedSize) {
        this.uploadedSize = uploadedSize;
    }

    public int getProgressStatus() {
        return progressStatus;
    }

    public void setProgressStatus(int progressStatus) {
        this.progressStatus = progressStatus;
    }

    public int getFileType() {
        return fileType;
    }

    public void setFileType(int fileType) {
        this.fileType = fileType;
    }

    public int getControlOption() {
        return controlOption;
    }

    public void setControlOption(int controlOption) {
        this.controlOption = controlOption;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getBussinessType() {
        return bussinessType;
    }

    public void setBussinessType(int bussinessType) {
        this.bussinessType = bussinessType;
    }

    public long getDuration() {
        return duration;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    public long getUploadTimestamp() {
        return uploadTimestamp;
    }

    public void setUploadTimestamp(long uploadTimestamp) {
        this.uploadTimestamp = uploadTimestamp;
    }

    public int getRetryCount() {
        return retryCount;
    }

    public void setRetryCount(int retryCount) {
        this.retryCount = retryCount;
    }

    public int getTranscodeProgress() {
        return transcodeProgress;
    }

    public void setTranscodeProgress(int transcodeProgress) {
        this.transcodeProgress = transcodeProgress;
    }

    public String getPersistentId() {
        return persistentId;
    }

    public void setPersistentId(String persistentId) {
        this.persistentId = persistentId;
    }

    public static final class Builder {
        private int id;
        private String parentId;
        private int parentType;
        private String userId;
        private String storeKey;
        private String fileLocalUrl;
        private String coverStoreKey;
        private String coverUrl;
        private long totalSize;
        private long uploadedSize;
        private int progressStatus;
        private int fileType;
        private int controlOption;
        private String title;
        private String description;
        private int bussinessType;
        private long duration;
        private long uploadTimestamp;
        private int retryCount;
        private int transcodeProgress;
        private String persistentId;

        private Builder() {
        }

        public Builder id(int id) {
            this.id = id;
            return this;
        }

        public Builder parentId(String parentId) {
            this.parentId = parentId;
            return this;
        }

        public Builder parentType(int parentType) {
            this.parentType = parentType;
            return this;
        }

        public Builder userId(String userId) {
            this.userId = userId;
            return this;
        }

        public Builder storeKey(String storeKey) {
            this.storeKey = storeKey;
            return this;
        }

        public Builder fileLocalUrl(String fileLocalUrl) {
            this.fileLocalUrl = fileLocalUrl;
            return this;
        }

        public Builder coverStoreKey(String coverStoreKey) {
            this.coverStoreKey = coverStoreKey;
            return this;
        }

        public Builder coverUrl(String coverUrl) {
            this.coverUrl = coverUrl;
            return this;
        }

        public Builder totalSize(long totalSize) {
            this.totalSize = totalSize;
            return this;
        }

        public Builder uploadedSize(long uploadedSize) {
            this.uploadedSize = uploadedSize;
            return this;
        }

        public Builder progressStatus(int progressStatus) {
            this.progressStatus = progressStatus;
            return this;
        }

        public Builder fileType(int fileType) {
            this.fileType = fileType;
            return this;
        }

        public Builder controlOption(int controlOption) {
            this.controlOption = controlOption;
            return this;
        }

        public Builder title(String title) {
            this.title = title;
            return this;
        }

        public Builder description(String description) {
            this.description = description;
            return this;
        }

        public Builder bussinessType(int bussinessType) {
            this.bussinessType = bussinessType;
            return this;
        }

        public Builder duration(long duration) {
            this.duration = duration;
            return this;
        }

        public Builder uploadTimestamp(long uploadTimestamp) {
            this.uploadTimestamp = uploadTimestamp;
            return this;
        }

        public Builder retryCount(int retryCount) {
            this.retryCount = retryCount;
            return this;
        }

        public Builder transcodeProgress(int transcodeProgress) {
            this.transcodeProgress = transcodeProgress;
            return this;
        }

        public Builder persistentId(String persistentId) {
            this.persistentId = persistentId;
            return this;
        }

        public UploadFile build() {
            return new UploadFile(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.id);
        dest.writeString(this.parentId);
        dest.writeInt(this.parentType);
        dest.writeString(this.userId);
        dest.writeString(this.storeKey);
        dest.writeString(this.fileLocalUrl);
        dest.writeString(this.coverStoreKey);
        dest.writeString(this.coverUrl);
        dest.writeLong(this.totalSize);
        dest.writeLong(this.uploadedSize);
        dest.writeInt(this.progressStatus);
        dest.writeInt(this.fileType);
        dest.writeInt(this.controlOption);
        dest.writeString(this.title);
        dest.writeString(this.description);
        dest.writeInt(this.bussinessType);
        dest.writeLong(this.duration);
        dest.writeLong(this.uploadTimestamp);
        dest.writeInt(this.retryCount);
        dest.writeInt(this.transcodeProgress);
        dest.writeString(this.persistentId);
    }

    protected UploadFile(Parcel in) {
        this.id = in.readInt();
        this.parentId = in.readString();
        this.parentType = in.readInt();
        this.userId = in.readString();
        this.storeKey = in.readString();
        this.fileLocalUrl = in.readString();
        this.coverStoreKey = in.readString();
        this.coverUrl = in.readString();
        this.totalSize = in.readLong();
        this.uploadedSize = in.readLong();
        this.progressStatus = in.readInt();
        this.fileType = in.readInt();
        this.controlOption = in.readInt();
        this.title = in.readString();
        this.description = in.readString();
        this.bussinessType = in.readInt();
        this.duration = in.readLong();
        this.uploadTimestamp = in.readLong();
        this.retryCount = in.readInt();
        this.transcodeProgress = in.readInt();
        this.persistentId = in.readString();
    }

    public static final Parcelable.Creator<UploadFile> CREATOR = new Parcelable.Creator<UploadFile>() {
        @Override
        public UploadFile createFromParcel(Parcel source) {
            return new UploadFile(source);
        }

        @Override
        public UploadFile[] newArray(int size) {
            return new UploadFile[size];
        }
    };
}
